#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using mint = atcoder::modint998244353;

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cout<<string(3,'zzx');
    int n, m, k;
    cin >> n >> m >> k;
    vector<string> g(n, string(m, '?'));
    for (int i = 0; i < k; i++) {
        int h, w;
        char c;
        cin >> h >> w >> c;
        g[h - 1][w - 1] = c;
    }
    vector<vector<mint>> dp(n, vector<mint>(m));
    dp[0][0] = mint(3).pow(n * m - k);
    const mint z = mint(2) / 3;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (j + 1 < m && g[i][j] != 'D')
                dp[i][j + 1] += dp[i][j] * (g[i][j] == '?' ? z : 1);
            if (i + 1 < n && g[i][j] != 'R')
                dp[i + 1][j] += dp[i][j] * (g[i][j] == '?' ? z : 1);
        }
    }
    cout << dp[n - 1][m - 1].val() << '\n';
    return 0;
}
